<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
	<head>
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<link rel="stylesheet" href="<%=request.getContextPath()%>/bootstrap/4.1.3/css/bootstrap.min.css">
		<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery-3.3.1.slim.min.js" ></script>
		<script type="text/javascript" src="<%=request.getContextPath()%>/js/popper.min.js"></script>
		<script type="text/javascript" src="<%=request.getContextPath()%>/bootstrap/4.1.3/js/bootstrap.min.js"></script>
		
		<style type="text/css">
			html,
			body {
			  height: 100%;
			}
			
			body {
			  display: -ms-flexbox;
			  display: -webkit-box;
			  display: flex;
			  -ms-flex-align: center;
			  -ms-flex-pack: center;
			  -webkit-box-align: center;
			  align-items: center;
			  -webkit-box-pack: center;
			  justify-content: center;
			  padding-top: 40px;
			  padding-bottom: 40px;
			  background-color: #f5f5f5;
			}
			
			.form-signin {
			  width: 100%;
			  max-width: 330px;
			  padding: 15px;
			  margin: 0 auto;
			}
			.form-signin .checkbox {
			  font-weight: 400;
			}
			.form-signin .form-control {
			  position: relative;
			  box-sizing: border-box;
			  height: auto;
			  padding: 10px;
			  font-size: 16px;
			}
			.form-signin .form-control:focus {
			  z-index: 2;
			}
			.form-signin input[type="password"] {
			  margin-bottom: 10px;
			  border-top-left-radius: 0;
			  border-top-right-radius: 0;
			}
		</style>
		<title>登录</title>
	</head>

<%
	String userName = "";
	String password = "";
	
	Cookie cookies[] = request.getCookies();
	if( cookies != null ){
		for( int i=0; i<cookies.length; i++){
			if("userName".equals(cookies[i].getName())){
				userName = cookies[i].getValue();
			}
			if("password".equals(cookies[i].getName())){
				password = cookies[i].getValue();
			}
		}
	}
%>

	<body class="text-center">
		<form class="form-signin" action="servlet/login.do" method="post" >
			<h1 class="h3 mb-3 font-weight-normal">用户登录	</h1>
			<label for="userName" class="sr-only">用户名</label>
			<input class="form-control" type="text" name="userName" 
				placeholder="请输入用户名" value="<%=userName%>">
		
			<label for="password" class="sr-only">密码：</label>
			<input class="form-control" type="password" name="password" 
				placeholder="请输入密码" value="<%=password%>">
				
			<div class="checkbox mb-3">
		        <label>
		          <input type="checkbox" name="remeberMe" value="remeberMe">
					下次自动登录
		        </label>
	      	</div>
			<button class="btn btn-lg btn-primary btn-block" type="submit">
				登   录
			</button>
		      <p class="mt-5 mb-3 text-muted">&copy; 2020-2021</p>
		</form>
	</body>
</html>